//
//  GlobalMacros.swift
//  SwiftLibrary
//
//  Created by xicheng on 16/2/18.
//  Copyright © 2016年 taurusxi. All rights reserved.
//

import UIKit

let kNaviHeight: CGFloat = 64
let kStatusBarHeight:CGFloat = 20

let kTabBarHeight: CGFloat = 49
let kMainScreenBounds = UIScreen.main.bounds
let kMainScreenWidth: CGFloat = UIScreen.main.bounds.width
let kMainScreenHeight: CGFloat = UIScreen.main.bounds.height
let kSingleLinePx:CGFloat = 1.0 / UIScreen.main.scale

let SYSTEM_VERSION = UIDevice.current.systemVersion

let CURRENT_APP_VERSION = Bundle.main.infoDictionary!["CFBundleShortVersionString"]

let iOS9Later = (UIDevice.current.systemVersion as NSString).floatValue >= 9.0

let iOS8Later = (UIDevice.current.systemVersion as NSString).floatValue >= 8.0

let kSocialIconheight:CGFloat = 54

let kResourcePath:String! = Bundle.main.resourcePath

let kDeviceScale:CGFloat = UIScreen.main.scale


let dateFormat = getDefaultFormat()

#if DEBUG
  
let DEBUG_FLAG = true
  
#else
  
let DEBUG_FLAG = false
  
#endif

let NETWORK_MOCK = false

private func getDefaultFormat()->DateFormatter{
  let dateFormat = DateFormatter()
  dateFormat.dateFormat = "YYYY-MM-dd HH:mm:ss.SSS"
  return dateFormat
}


let uploadDateFormat = getUploadDefaultFormat()

private func getUploadDefaultFormat()->DateFormatter{
  let dateFormat = DateFormatter()
  dateFormat.dateFormat = "YYYY_MM_dd-HH_mm_ss"
  return dateFormat
}

func TX_getUploadString()->String {
  
  return uploadDateFormat.string(from: Date())
}


func TX_CLAMP(_ _x_:CGFloat,_ _low_:CGFloat,_ _high_:CGFloat)->CGFloat {
  return ((_x_) > (_high_)) ? (_high_) : (((_x_) < (_low_)) ? (_low_) : (_x_))
}

func TXLogError(_ msg: @autoclosure ()->String){
  guard DEBUG_FLAG else {
    return
  }
  print("\(dateFormat.string(from: Date())) [One Day] 💔 ERROR 💔 \(msg())\n")
}

func TXLogWarn(_ msg: @autoclosure ()->String){
  guard DEBUG_FLAG else {
    return
  }
  print("\(dateFormat.string(from: Date())) [One Day] 💛 WARN 💛 \(msg())\n")
}


func TXLogInfo(_ msg: @autoclosure ()->String){
  guard  DEBUG_FLAG else {
    return
  }
  print("\(dateFormat.string(from: Date())) [One Day] 💚 INFO 💚 \(msg()) \n")
  
}
#if DEBUG
  func TXLogDebug(_ msg: @autoclosure ()->String,_ function:String=#function){
    guard DEBUG_FLAG else {
      return
    }
    
    print("\(dateFormat.string(from: Date())) [One Day] 💙 DEBUG Function:[\(function)] 💙 \(msg()) \n")
    
  }
  
#else
  func TXLogDebug(_ msg: @autoclosure ()->String){
  }
#endif

